<?php

	// Include the PHP TwilioRest library
	require "twilio.php";
	
	// Twilio REST API version
	$ApiVersion = "2010-04-01";

	// Set our AccountSid and AuthToken
	$AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
	$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";

	// Instantiate a new Twilio Rest Client
	$client = new TwilioRestClient($AccountSid, $AuthToken);

	// make an associative array of server admins
	$people = array(
		"4158675309"=>"Johnny",
		"4158675310"=>"Helen",
		"4158675311"=>"Virgil",
	);

	// Iterate over all our server admins
	foreach ($people as $number => $name) {

		// Send a new outgoinging SMS by POST'ing to the SMS resource */
		// YYY-YYY-YYYY must be a Twilio validated phone number
		$response = $client->request("/$ApiVersion/Accounts/$AccountSid/SMS/Messages", 
			"POST", array(
			"To" => $number,
			"From" => "YYY-YYY-YYYY",
			"Body" => "Bad news $name, the server is down and it needs your help"
		));
		if($response->IsError)
			echo "Error: {$response->ErrorMessage}";
		else
			echo "Sent message to $name";
	}

?>
